<template>
  <view class="isShow-login">
   <view class="login-box">
     <icon class="iconfont icon-guanbi05" @click="showLoginFrame"></icon>
     <text class="login-title">需要先授权获取个人信息</text>
     <button class="login-button" open-type="getPhoneNumber" type="primary" @getphonenumber="getUserInfo">微信账号快速授权</button>
     <view class="checked-contract">
       <view class="checked" @click="changeSelectContract">
         <i class="good-checked" v-if="selectContract"></i>
       </view>
       <view class="contract">同意遵守<text class="contract-text">《日内瓦条约》</text></view>
     </view>
   </view>
  </view>
</template>

<script setup>
  import { ref } from "vue";
  const emit = defineEmits(['showValue'])
  const showLogin = ref(true)
  const showLoginFrame = () => {
    showLogin.value = !showLogin.value
    emit('showValue',showLogin.value)
  }
  // 遵守合同开关
  const selectContract = ref(false)
  const changeSelectContract = () => {
    selectContract.value = !selectContract.value
  }
  
  // 点击授权微信登录
  const isLogin = ref(true)
  const getUserInfo = (e) => {
    if(!selectContract.value) return uni.$showMsg('请点击同意遵守相关合同')
    isLogin.value = false
    console.log(e,'222');
    wx.login({
          success: function (res) {
            console.log(res);
             let code = res.code // 登录凭证code
          }
       }) 
  }
  
</script>

<style lang="scss">
  .isShow-login {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    .login-box {
      position: relative;
      width: 700rpx;
      height: 320rpx;
      background-color: #fff;
      border-radius: 50rpx;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      .icon-guanbi05 {
        position: absolute;
        right:24rpx;
        top: 18rpx;
        font-size: 50rpx;
        color: #999;
      }
      .login-title {
        font-size: 35rpx;
      }
      .login-button {
        width: 500rpx;
        height: 100rpx;
        text-align: center;
        line-height: 100rpx;
        color: #fff;
        font-size: 40rpx;
        font-weight: 600;
        margin: 30rpx 0 18rpx 0;
        border-radius: 40rpx;
        box-shadow: 0 0 6rpx #999;
      }
      .checked-contract {
        display: flex;
        align-items: center;
        .checked {
          width: 25rpx;
          height: 25rpx;
          border: 1rpx solid #000;
          border-radius: 12rpx;
          display: flex;
          justify-content: center;
          align-items: center;
          margin-right: 10rpx;
          .good-checked {
            width: 18rpx;
            height: 18rpx;
            border-radius: 9rpx;
            background-color: #00b26a;
          }
        }
        .contract {
          font-size: 30rpx;
          .contract-text {
            color: #00b26a;
          }
        }
      }
    }
  }

</style>